#include <stdio.h>
#include <stdlib.h>
#include <string.h>


int main(int arg, char* argvs[]){
	char* fileout;
	char* program;
	char* grafos;
	char** opcoes;
	opcoes = malloc(sizeof(char*)*(arg - 4));
	long i, j, l;
	grafos = argvs[1];
	fileout = argvs[2];
	program = argvs[3];
	for(i = 4; i < arg; i++)opcoes[i-4] = argvs[i];

	FILE* fg = fopen(grafos, "r");
	long numg;
	char nameg[100];
	fscanf(fg, "%lu", &numg);
	char string[400];

	for(i = 0; i < numg; i++){
		fscanf(fg, "%s", nameg);
		for(j = 0; j < 10; j++){
			strcpy(string, program);
			strcat(string, nameg);
			strcat(string, fileout);
			for(l = 4; l < arg; l++)strcat(string, opcoes[l-4]);
			system(string);
		}
	}

	fclose(fg);
	return 0;
}
